//package com.dotflat.vod.controller;
//
//import com.dotflat.vod.service.YZTokenService;
//import com.matt.commons.exception.BusinessException;
//import com.matt.foundation.model.ErrorCode;
//import com.tuo51.foudation.model.StatusResponse;
//import com.youzan.cloud.open.sdk.common.exception.SDKException;
//import com.youzan.cloud.open.sdk.core.client.auth.Token;
//import com.youzan.cloud.open.sdk.core.client.core.DefaultYZClient;
//import com.youzan.cloud.open.sdk.gen.v1_0.api.YouzanEduProductAggregateQueryPage;
//import com.youzan.cloud.open.sdk.gen.v1_0.model.YouzanEduProductAggregateQueryPageParams;
//import com.youzan.cloud.open.sdk.gen.v1_0.model.YouzanEduProductAggregateQueryPageResult;
//import io.swagger.annotations.Api;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import static com.matt.foundation.constant.RequestConstant.TICKET;
//
//
///**
//
// * @author wangxuchuan
//
// * @date 2020/10/30
//
// */
//
//@RestController
//@Slf4j
//@RequestMapping("/api/yz/product")
//@Api(tags = "有赞教育 - 商品信息（支持类型内容、专栏、直播和线下课）")
//public class YZProductController {
//
//    @Autowired
//    private YZTokenService yzTokenService;
//
//    @Autowired
//    private DefaultYZClient yzClient;
//
//    @GetMapping("/list")
//    public StatusResponse getProducts(@RequestHeader(TICKET) String ticket,
//                                      @RequestParam(required = false, defaultValue = "created_at")String orderBy, @RequestParam(required = false, defaultValue = "DESC") String direction,
//                                      @RequestParam(required = false, defaultValue = "0")int pageNum,  @RequestParam(required = false, defaultValue = "20")int pageSize,
//                                      @RequestParam(required = false, defaultValue = "true") boolean countEnabled,
//                                      @RequestParam(required = false) String keyword
//                                      ){
//
//        //YouZanClient 建议全局唯一,使用 spring 容器管理
//        Token token = yzTokenService.yzCloudToken();
//
//        YouzanEduProductAggregateQueryPage youzanEduProductAggregateQueryPage = new YouzanEduProductAggregateQueryPage();
//
//        //创建参数对象,并设置参数
//        YouzanEduProductAggregateQueryPageParams youzanEduProductAggregateQueryPageParams = new YouzanEduProductAggregateQueryPageParams();
//
//        YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsPagerequest youzanEduProductAggregateQueryPageParamsPageRequest  = new YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsPagerequest();
//        youzanEduProductAggregateQueryPageParams.setPageRequest(youzanEduProductAggregateQueryPageParamsPageRequest);
//
//        YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsSort youzanEduProductAggregateQueryPageParamsSort  = new YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsSort();
//        youzanEduProductAggregateQueryPageParamsPageRequest.setSort(youzanEduProductAggregateQueryPageParamsSort);
//
//        List<YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsOrders> ordersList = new ArrayList<>();
//        youzanEduProductAggregateQueryPageParamsSort.setOrders(ordersList);
//        YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsOrders youzanEduProductAggregateQueryPageParamsOrders  = new YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsOrders();
//        youzanEduProductAggregateQueryPageParamsOrders.setProperty(orderBy);
//        youzanEduProductAggregateQueryPageParamsOrders.setDirection(direction);
//        ordersList.add(youzanEduProductAggregateQueryPageParamsOrders);
//
//
//        youzanEduProductAggregateQueryPageParamsPageRequest.setPageNumber(pageNum + 1);
//        youzanEduProductAggregateQueryPageParamsPageRequest.setCountEnabled(countEnabled);
//        youzanEduProductAggregateQueryPageParamsPageRequest.setPageSize(pageSize);
//
//
//        YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsQuery youzanEduProductAggregateQueryPageParamsQuery = new YouzanEduProductAggregateQueryPageParams.YouzanEduProductAggregateQueryPageParamsQuery();
//        youzanEduProductAggregateQueryPageParams.setQuery(youzanEduProductAggregateQueryPageParamsQuery);
//        youzanEduProductAggregateQueryPageParamsQuery.setShowSoldOut(0);
//        if (StringUtils.isNotEmpty(keyword)){
//            youzanEduProductAggregateQueryPageParamsQuery.setTitle(keyword);
//        }
//
//        youzanEduProductAggregateQueryPage.setAPIParams(youzanEduProductAggregateQueryPageParams);
//        try {
//            YouzanEduProductAggregateQueryPageResult result = yzClient.invoke(youzanEduProductAggregateQueryPage, token, YouzanEduProductAggregateQueryPageResult.class);
//
//            return StatusResponse.success(result);
//        } catch (SDKException e) {
//            e.printStackTrace();
//            throw new BusinessException(ErrorCode.TZ_REQUEST_EXCEPTION, "内训系统接口请求失败");
//        }
//    }
//
//}